//
//  DownManager.m
//  ManKeCartoon
//
//  Created by 邹功梁 on 15/10/29.
//  Copyright © 2015年 ManKe. All rights reserved.
//

#import "DownManager.h"

@implementation DownManager

- (NSString *)documentPath
{
     NSString *documentString = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    return documentString;
}

+ (NSString *)createDocumentFile:(NSString *)file
{
    DownManager *manager = [[DownManager alloc] init];
    NSString *newFile = [[manager documentPath] stringByAppendingPathComponent:file];
    return newFile;
}

+ (NSString *)createSubDocumentFile:(NSString *)file subFile:(NSString *)subFile
{
    NSString *path = [DownManager createDocumentFile:file];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    [fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
    NSString *subFilePath = [path stringByAppendingPathComponent:subFile];
    [fileManager createDirectoryAtPath:subFilePath withIntermediateDirectories:YES attributes:nil error:nil];
    return subFilePath;
}
+ (void)deleteDocumentFile:(NSString *)key
{
    NSString *path = [DownManager createDocumentFile:key];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    [fileManager removeItemAtPath:path error:nil];
}

@end
